using CxRomos.Core.Services;
using CxRomos.Web.UserControls.Intefaces;
using StructureMap;

namespace CxRomos.Web.UserControls.Presenters {
    public class LoginLinksPresenter {
        private IUserSession _userSession;
        private IRedirector _redirector;
        private IAccountService _accountService;

        public void Init(ILoginLinks view) {
            _userSession = ObjectFactory.GetInstance<IUserSession>();
            _redirector = ObjectFactory.GetInstance<IRedirector>();
            _accountService = ObjectFactory.GetInstance<IAccountService>();

            view.ShowAppropriateLoginStatePanel(_userSession.LoggedIn, _userSession.Username);
        }

        public void LogOut() {
            _accountService.Logout();
        }

        public void LogIn() {
            _redirector.GoToAccountLoginPage();
        }

        public void Register() {
            _redirector.GoToAccountRegisterPage();
        }

        public void Home() {
            _redirector.GoToHomePage();
        }

        public void EditAccount() {
            _redirector.GoToAccountEditAccountPage();
        }
 
    }
}